/****************************************************************************
 * Copyright 2009 Huascar A. Sanchez                                        *
 *                                                                          *
 * Licensed under the Apache License, Version 2.0 (the "License");          *
 * you may not use this file except in compliance with the License.         *
 * You may obtain a copy of the License at                                  *
 *                                                                          *
 *     http://www.apache.org/licenses/LICENSE-2.0                           *
 *                                                                          *
 * Unless required by applicable law or agreed to in writing, software      *
 * distributed under the License is distributed on an "AS IS" BASIS,        *
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
 * See the License for the specific language governing permissions and      *
 * limitations under the License.                                           *
 ****************************************************************************/
package com.gotobject.jumpstart.graphics;

import javax.swing.SwingUtilities;
import javax.swing.JFrame;
import javax.swing.JDialog;
import java.util.List;
import java.util.Arrays;
import java.awt.Toolkit;
import java.awt.Dimension;

/**
 * @author huascar.sanchez@gmail.com (Huascar A. Sanchez)
 */
public class RunCommandWindow {

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {

                JFrame frame = new JFrame();
                frame.setSize(600, 400);
                frame.setVisible(true);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//                JTextField textField = new JTextField("foo bar");
//                textField.setOpaque(false);

                CommandDisplay hud =  new CommandDisplay("Welcome to Bella! Enter your command or type 'help?' for assistance.",frame);
                CommandDisplay hud2 = new CommandDisplay(frame);
                CommandDisplay hud3 = new CommandDisplay(frame);
//                hud.getContentPane().add(textField);
                hud2.hideTitle();

                JDialog dialog = hud.commandWindow();

                //JDialog d2     = hud2.commandWindowTest();

                hud.hideTitle();
                //hud.makeResizeable();


//                d2.setSize(500, 120);
//                d2.setLocationRelativeTo(null);
//                d2.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
//                d2.setVisible(true);

//                WindowUtils.createAndInstallRepaintWindowFocusListener(frame);
//                dialog.setSize(500, 120);
//                //dialog.setLocationRelativeTo(null);
                dialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
                int xCoord = (screen.width/2 - dialog.getWidth()/2);
                int yCoord = (screen.height/2 - dialog.getHeight()/2);
                System.out.println(String.format("x%d y%d", xCoord - 350, yCoord - 300));
                dialog.setLocation(40, yCoord + 400 );
                
                dialog.setVisible(true);
                final List<String> commands = Arrays.asList("Open the house's door", "Place image on canvas", "please stop now");
                hud.enterCommand("");
                //hud2.enterCommand("");
                //hud2.enterCommand(commands);
            }
        });
    }
}
